# -*- coding: utf-8 -*-

#惰性奇数序列
def _odd_iter():
    n = 1
    while True:
        n = n + 2
        yield n

def _not_divisible(n):
    return lambda x: x % n > 0
#素数无限序列，输出时注意截止条件
def primes():
    it = _odd_iter()
    while True:
        n = next(it)
        yield n
        it = filter(_not_divisible(n), it)

for i in primes():
    if i < 1000:
        print(i)
    else:
        break